package com.hjy.websocket.domain;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@ApiModel("响应实体类")
public class WbsocketResponseBody {
    @ApiModelProperty(value = "成功或失败", example = "success", dataType = "string")
    private String status;

    @ApiModelProperty(value = "执行失败原因", example = "用户不存在", dataType = "string")
    private String msg;

    @ApiModelProperty(value = "响应数据集", example = "", dataType = "object")
    private Object data;

    private String clientIp;

    private String methodName;

    private String connId;
    public WbsocketResponseBody() {

    }

    public WbsocketResponseBody(String status, Object data) {
        this.status = status;
        this.data = data;
    }

    public WbsocketResponseBody(String status, String msg) {
        this.status = status;
        this.msg = msg;
    }

    public static WbsocketResponseBody success(Object data) {
        return new WbsocketResponseBody("success", data);
    }


    public static WbsocketResponseBody error(String msg) {
        return new WbsocketResponseBody("failed", msg);
    }


}
